<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p id="show"></p>
    <script src="utils.js"></script>

    <script>
        //获取未来的时间和当前时间
        var time1 = new Date('2020-06-25 00:00:00')
        var time2 = new Date()
        console.log(timeDiff)
        // 获取时间差
        timeDiff(time1,time2,function(value){
            //输出到页面上
            show.innerHTML = '距离端午节还有 ' + value.day + '天' + value.hours + '小时' + value.minutes + '分' + value.seconds + '秒'
        })
        // 定时器获取最新时间
        setInterval(function () {
            //刷新当前时间
            time2 = new Date();
            //输出到页面上
            timeDiff(time1, time2, function (value) {
                show.innerHTML = '距离端午节还有 ' + value.day + '天' + value.hours + '小时' + value.minutes + '分' + value.seconds + '秒'
            })
        }, 1000)
    </script>
</body>
</html>